#include "../../src/led.h"
#include "../unity/unity.h"
#include "../unity/unity_internals.h"
#include "../mock/gpio.h"

#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>

static void test_led_on(void) 
{
    int32_t err_code = led_init();
    TEST_ASSERT(err_code == 0);

    led_on(GPIO0, 10);
    for (int i = 0; i < 5; i++) {
        lcd_ctrl();
    }
    TEST_ASSERT_EQUAL_INT32(1, led_get_state());

    for (int i = 0; i < 5; i++) {
        lcd_ctrl();
    }
    TEST_ASSERT_EQUAL_INT32(0, led_get_state());
}

static void test_led_off(void) 
{
    int32_t err_code = led_init();
    TEST_ASSERT(err_code == 0);

    led_on(GPIO0, 10);
    TEST_ASSERT_EQUAL_INT32(1, led_get_state());

    led_off(GPIO0);
    TEST_ASSERT_EQUAL_INT32(0, led_get_state());
}

//////////////////////////////////////////////
void setUp(void) {
    // set stuff up here
}

void tearDown(void) {
    // clean stuff up here
}

int main(void) {
    UNITY_BEGIN();
    RUN_TEST(test_led_on);
    RUN_TEST(test_led_off);
    return UNITY_END();
}
